﻿using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;

namespace DKPScoreWebApi.Models
{
    /// <summary>
    /// 积分记录实体类
    /// 记录成员每次获得或消耗积分的详细信息
    /// </summary>
    public class PointRecord
    {
        /// <summary>
        /// 记录ID，主键，自增
        /// </summary>
        [Key]
        public int Id { get; set; }

        /// <summary>
        /// 所属工会ID，外键关联Guild
        /// </summary>
        [Required]
        public int GuildId { get; set; }

        /// <summary>
        /// 成员ID，外键关联GuildMember
        /// </summary>
        [Required]
        public int MemberId { get; set; }

        /// <summary>
        /// 积分项目ID，外键关联PointItem
        /// </summary>
        [Required]
        public int ItemId { get; set; }

        /// <summary>
        /// 获得的积分值，正数表示获得，负数表示消耗
        /// </summary>
        [Required]
        public int PointsEarned { get; set; }

        /// <summary>
        /// 进度值，仅progress类型项目使用
        /// </summary>
        public int ProgressValue { get; set; }

        /// <summary>
        /// 记录描述，说明积分获取或消耗的原因
        /// </summary>
        [MaxLength(200)]
        public string Description { get; set; }

        /// <summary>
        /// 副本名称，记录积分相关的副本活动
        /// </summary>
        [MaxLength(100)]
        public string RaidName { get; set; }

        /// <summary>
        /// 副本日期，记录活动发生的时间
        /// </summary>
        public DateTime? RaidDate { get; set; }

        /// <summary>
        /// 记录创建者ID，外键关联WxUser
        /// </summary>
        [Required]
        public int CreatedBy { get; set; }

        /// <summary>
        /// 记录创建时间
        /// </summary>
        public DateTime CreatedAt { get; set; } = DateTime.Now;

        // 导航属性
        /// <summary>
        /// 所属工会信息
        /// </summary>
        [ForeignKey("GuildId")]
        public virtual Guild Guild { get; set; }

        /// <summary>
        /// 相关成员信息
        /// </summary>
        [ForeignKey("MemberId")]
        public virtual GuildMember Member { get; set; }

        /// <summary>
        /// 相关积分项目信息
        /// </summary>
        [ForeignKey("ItemId")]
        public virtual PointItem PointItem { get; set; }

        /// <summary>
        /// 记录创建者信息
        /// </summary>
        [ForeignKey("CreatedBy")]
        public virtual WxUser Creator { get; set; }
    }
}
